package hms.inventory;

/**
 * InvColor is an inventory color.
 * 
 * @author Akilah McIntyre
 */
public class InvColor {
	/**
	 * unique identifier of an inventory color
	 */
	public int color_id = -1;
	/**
	 * name of an inventory color
	 */
	public String color_name = "";

	/**
	 * Constructs an inventory color from an unique identifier and a name.
	 * 
	 * @param colorID
	 *            unique identifier of an inventory color
	 * @param colorName
	 *            name of of an inventory color
	 * 
	 **/
	public InvColor(int colorID, String colorName) {
		this.color_id = colorID;
		this.color_name = colorName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + color_id;
		result = prime * result
				+ ((color_name == null) ? 0 : color_name.hashCode());
		return result;
	}

	/**
	 * Compares two inventory colors for equality. The result is true if and
	 * only if the argument is not null and is a InvColor object has the same
	 * unique identifier and name as this object.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof InvColor)) {
			return false;
		}
		InvColor other = (InvColor) obj;
		if (color_id != other.color_id) {
			return false;
		}
		if (color_name == null) {
			if (other.color_name != null) {
				return false;
			}
		} else if (!color_name.equals(other.color_name)) {
			return false;
		}
		return true;
	}

	/**
	 * Returns a string representation of this InvColor, which is color_name
	 **/
	public String toString() {
		return color_name;
	}

}
